﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;
using DataAccess;

namespace BaseWeb.GridView.ExpandGrid.Modules
{
    public partial class TreeGridModule : System.Web.UI.UserControl
    {
        public string ProductUrl
        {
            get { return ("../../GridView/ExpandGrid/ShowStudentList.aspx"); }
        }



        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindRepeater();
            }
        }

        private void BindRepeater()
        {
            var list = CommonSystem.Instance.Service.GetAllList<li_Class>();
            this.Repeater1.DataSource = list;
            this.Repeater1.DataBind();
        }

        protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var dataItem = e.Item.DataItem as li_Class;
                var lnkClassName = e.Item.FindControl("lnkClassName") as LinkButton;
                var labGrade = e.Item.FindControl("labGrade") as Label;
                var hidUrl = e.Item.FindControl("hidUrl") as HiddenField;

                if (dataItem != null)
                {

                    if (lnkClassName != null)
                    {
                        lnkClassName.Text = dataItem.ClassName;// 子项编号
                        //if (labIsRegistered.Text.Contains("已登记"))
                        //{
                        //    lnkChildNumber.ForeColor = System.Drawing.Color.Blue;
                        //    var url = "../JointlyCheckupSign/JointlyCheckupSignCompleted.aspx?ProjectChildKeyId=" + dataItem.KeyId;
                        //    lnkChildNumber.OnClientClick = "ViewInfo(\"" + url + "\")";
                        //}
                        //else
                        //{
                        //    lnkChildNumber.OnClientClick = "return false;";
                        //}
                        lnkClassName.OnClientClick = "return false;";
                    }
                    if (labGrade != null) labGrade.Text = dataItem.Grade;//子项名称 
                    if (hidUrl != null) hidUrl.Value = string.Format("{0}?ClassId={1}", this.ProductUrl, dataItem.KeyId);  //绑定成品信息页面url
                }


            }
        }

    }
}